Technote 1100Color Picker 2.1Apple Developer Technical Support (DTS) |
CONTENTSDetermining If a
Picker is Installed |
With the release of Mac OS 8.0, Apple has redesigned and expanded the Color Picker. In doing so, we have changed the Color Picker APIs for developers and expanded on the number and kind of pickers that are available to the end user. This Technote outlines these changes in detail. This Note is primarily intended for developers who use or are interested in using the Color Picker Manager APIs. Note: You should also be familiar with the 'Dialog Manager' chapter of Inside Macintosh:Macintosh Toolbox Essentials and the 'Component Manager' chapter of Inside Macintosh:More Macintosh Toolbox. |
Color Picker 2.1 OverviewThe Color Picker Manager supplies your application with functions and a standard user interface for asking the user for color choices. Your application can use these APIs to interact with the Color Picker Extension and also to create your own custom color picker. System Requirements
Dependencies
Licensing
Download
Gestalt
New Features
New Color PickersThere are many new pickers with the 2.1 release: CMYK Picker, Crayon Picker, HSV Picker and an HTML Picker. This section overviews these new pickers and shows you what they look like. CMYKThis is a slider-based picker for selecting a color in CMYK color space. This picker is mainly intended for use in the color pre-press industry since a majority of printing devices out there use this color space. CrayonThe Crayon picker is targeted at the home and school market. It presents a box of 60 crayon colors from which the user can select. HSVThe original Color Picker 1.0 (the dartboard as it's affectionately called at Apple) was an HSV picker (although it called itself a Hue, Saturation, and "Brightness" picker ). This picker was removed with the 2.0 release, however many users liked it and asked for its return. Therefore, for users who became comfortable working in that color space, we have added it back into Color Picker 2.1. It has the "wheel and slider" interface much like the original 1.0 picker. HTMLThis is basically another RGB slider-based color picker. The units though are in hexadecimal bytes and a combined HTML tag is maintained as a fourth text-edit field (so if the sliders read 99 for red, 66 for green and CC for blue, the combined HTML tag text field will contain #9966CC). Many HTML commands take this kind of composite "hash-mark-with-RGB-hex" format. Determining If a Picker Is InstalledAs a developer, you may wish to know whether a particular picker is installed on your user's machine. To accomplish this you need to complete two steps: 1. Check the Gestalt selector
2. Then use the Component Manager
to query for a specific type of picker. All Apple color
pickers use a manufacturer type of 'appl', a type of 'cpkr'
and a sub-type that reflects the color space of the picker
(as defined in ColorSync's The subtypes for the various color pickers are: CMYK Picker = As an example, to see if Apple's
CMYK picker exists on your user's system, you would set up
your
NOTE: Third party pickers and future color pickers may use some of the same subtypes or new ones. Therefore, you could potentially get back more than one picker during your Component Manager query. See the 'Component Manager' chapter of Inside Macintosh: More Macintosh Toolbox for further details. |
Color Picker 2.1 APIsTo download new header files click here In Apple's studies, we realized that a majority of the Color Picker APIs were not being used by developers. Therefore, with the Color Picker 2.1 release, a lot of the APIs have become obsolete. This section covers new, old, supported and unsupported/removed APIs. If you have a need for one of the obsolete APIs, please let Developer Support know at feedback and we will attempt to get the API reinstated or give you another way to implement the same functionality. New APIHere is the one new Color Picker 2.1 call (ColorSync 2 savvy):
theColorInfo :
A color picker parameter block, which is described on page 2-21 of the Advanced Color Imaging Reference. With Color Picker 2.1, however, where profile handles were used with Color Picker 2.0, profile references are nowused for this API. DESCRIPTION This call is identical to Maintained APIsHere are the original Color Picker 1.0 calls that we are keeping and maintaining: pascal SmallFract Fix2SmallFract(Fixed f); pascal Fixed SmallFract2Fix(SmallFract s); pascal void CMY2RGB(const CMYColor *cColor, RGBColor *rColor); pascal void RGB2CMY(const RGBColor *rColor, CMYColor *cColor); pascal void HSL2RGB(const HSLColor *hColor, RGBColor *rColor); pascal void RGB2HSL(const RGBColor *rColor, HSLColor *hColor); pascal void HSV2RGB(const HSVColor *hColor, RGBColor *rColor); pascal void RGB2HSV(const RGBColor *rColor, HSVColor *hColor); pascal Boolean GetColor(Point where, ConstStr255Param prompt, const RGBColor *inColor, RGBColor *outColor); Here is the one Color Picker 2.0 call we are keeping and maintaining:
NOTE: Please see the 'Advanced Color Imaging' book for complete details on these APIs. Obsolete APIsHere are the Color Picker 2.0 and 2.1 calls we have removed: AddPickerToDialog CreateColorDialog CreatePickerDialog DisposeColorPicker GetPickerVisibility SetPickerVisibility SetPickerPrompt DoPickerEvent DoPickerEdit DoPickerDraw GetPickerColor SetPickerColor GetPickerOrigin SetPickerOrigin GetPickerProfile SetPickerProfile GetPickerEditMenuState SetPickerColorChangedProc NCreateColorDialog NGetPickerColor NSetPickerColor NGetPickerProfile NSetPickerProfile NSetPickerColorChangedProc ExtractPickerHelpItem If you have a need for one of these APIs, please contact feedback. |
Eye Dropper ToolFor a picker developer, the eye dropper tool is probably the single-most significant addition to Color Picker 2.1. If the user holds down the Option key, the cursor will change to an eyedropper and the user will "pick up" the color under the cursor. This section describes how this feature is implemented and how your application can take advantage of it. OverviewThe way this tool was created is rather straightforward,
but is a little tedious to explain. Recall that beginning
with Color Picker 2.0, color pickers have been component
based (that is, using the Component Manager). Individual
color pickers are loaded and instantiated as the user
browses through them in the Color Picker dialog. The way the
Color Picker Manager interacts with the individual color
picker components is through Component Manager-based
messages. The Color Picker has defined many messages for
things such as passing events to the picker, telling the
color picker to redraw itself, telling the color picker to
set the "new" color, etc. In terms of the eyedropper tool,
two messages are particularly important: the In Color Picker 2.0, the individual pickers were sent
only two In Color Picker 2.1, things have changed a bit. First of
all, you can no longer be assured that your picker will
receive only the initial two Instructions and Warnings1. The Color Picker Manager may change the cursor on you (to the eyedropper cursor). It is the picker's responsibility to change it back. If your color picker is handling cursor updates during null events, you need do nothing more. One third party picker was doing no cursor updating at all this would leave the cursor as an eyedropper even though the user had let up on the option key. A well-written color picker will always handle cursor updating for example, when the user moves the cursor over a text edit field the cursor should turn into an I-beam cursor, etc. 2. Since color pickers should be handling cursor updating during null events, all null events are suspended while the option key is held down. If this were not the case, there would be a sort of tug-of-war between the Color Picker Manager and the individual color pickers the Color Picker Manager would be fighting to set the cursor to an eyedropper while the picker was trying to set it to an arrow or whatever. 3. Finally, recall also that the Color Picker can be
called moveable modal (using the more mid-level API calls
like The strictly modal case is quite another situation. Since
it is a non-moveable modal dialog, there never was any
context switching behavior to preserve. In fact, the only
thing the user would expect from clicking in the Desktop
from a modal dialog is a By the way, the Color Picker handles
all the hit-testing etc. by building the hit-test region
so that when the cursor is within
this region and the option key is down, they get an
eyedropper; otherwise they don't. For the moveable-modal
case, we walk the current layers window list accumulating
window regions. In the strictly modal case, we use Finally, make sure you update the cursor during null
events passed your picker and also be able to handle New Component Manager MessagesFor new header files click here If you wish to write a Color Picker component or if you wish to revise a Color Picker component you have already written, there are some new Color Picker messages you may want to implement.
|
|
Thanks to Mike Bitz, Tim Carroll, and Dave Polaschek.